﻿using System;

namespace Common
{
    public interface ICache
    {
        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T Get<T>(string key);

        /// <summary>
        /// 删除缓存
        /// </summary>
        /// <param name="key"></param>
        void Remove(string key);

        /// <summary>
        /// 设置缓存，并且永久有效
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="cache"></param>
        /// <returns></returns>
        T Set<T>(string key, T cache);


        /// <summary>
        /// 设置缓存，并设置过期时间
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="cache"></param>
        /// <param name="expiressAbsoulte"></param>
        /// <returns></returns>
        T Set<T>(string key, T cache, DateTimeOffset expiressAbsoulte);
    }
}
